<template>
	<view class="course-item" v-bind:class="{column:flag===1,row:flag===2}" @click="goDetail(kcItem.id)">
		<view class="item-left">
			<image class="course-img" :src="kcItem.mainImage">
			</image>
			<view class="course-time">{{kcItem.totalTime}}</view>
		</view>
		<view class="item-right column">
			<view class="title">{{kcItem.title}}</view>
			<view class="info">
				<view class="nickname iconfont icon-laoshi2">{{kcItem.nickName}}</view>
				<view class="count">
					<view :class="{'money':true,'iconfont':kcItem.isFree == 0,'icon-moneybag':kcItem.isFree == 0}">
						{{kcItem.isFree == 1?"免费":kcItem.priceDiscount}}
					</view>
					<view class="xue iconfont icon-video">{{kcItem.studyTotal}} 人在学</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			kcItem: {
				type: Object,
				default: {}
			},
			name: {
				type: String,
				default: ""
			},
		},
		data() {
			return {
				flag: 2
			}
		},
		created() {
			if (this.name === "新") {
				this.flag = 1
			} else {
				this.flag = 2
			}
		},
		methods: {
			goDetail(id) {
				uni.navigateTo({
					url: `/pages/course/course-details?id=${id}`
				})
			}
		}
	}
</script>

<style lang="scss">
	.row {
		display: flex;
		justify-content: start;
	}

	.column {
		display: flex;
		justify-content: start;
		flex-direction: column;
	}

	.course-item {
		width: 660rpx;
		height: 202rpx;
		padding: 20rpx 0;

		.item-left {
			position: relative;
			width: 290rpx;
			height: 160rpx;
			margin-right: 20rpx;

			.course-img {
				width: 290rpx;
				height: 160rpx;
				border-radius: 14rpx;
			}

			.course-time {
				position: absolute;
				bottom: 2px;
				right: 2px;
				font-size: 11px;
				color: #fff;
				background: rgba(51, 51, 51, .4);
				border-radius: 10px;
				padding: 0 4px;
			}
		}

		.item-right {
			.title {
				max-width: 182px;
				height: 35px;
				line-height: 17px;
				font-size: 14px;
				font-weight: 700;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: normal;
			}

			.info {
				.nickname {
					font-size: 11px;
					color: #999;
				}

				.count {
					display: flex;
					align-items: center;
					justify-content: start;

					.money {
						color: #fb6932;
						width: 65px;
						font-size: 14px;
					}

					.xue {
						font-size: 11px;
						color: #222;

					}
				}
			}
		}
	}
</style>
